﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nim.AI
{
    public class NimState
    {
        private List<NimMove> moves;

        public NimState()
        {
            moves = new List<NimMove>();
        }

        //Adds a move
        public void AddMove(NimMove move)
        {
            if(!MoveExists(move)) moves.Add(move);
        }

        //Returns all of the moves for a particular state
        public List<NimMove> GetMoves()
        {
            return moves;
        }

        //Checks and sees if a move already exists
        public bool MoveExists(NimMove move)
        {
            bool exists = false;

            foreach (NimMove nimMove in moves)
            {
                if (move.Number == nimMove.Number && move.Row == nimMove.Row) exists = true;
            }

            return exists;
        }

        //Gets a particular move
        public NimMove GetMove(int row, int number)
        {
            NimMove move = null;

            foreach(NimMove nimMove in moves){
                if (nimMove.Row == row && nimMove.Number == number) move = nimMove;
            }

            return move;
        }
    }
}
